<html style="font-size: 100px; visibility: visible;" class="no-js" xmlns:th="http://www.thymeleaf.org">
<head>
    <script type="text/javascript">Object.defineProperty(window.navigator, 'userAgent', {
        get: function () {
            return 'Mozilla/5.0 (Linux; U; Android 5.1.1; en-us; KIW-AL10 Build/HONORKIW-AL10) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/1.0.0.100 U3/0.8.0 Mobile Safari/534.30 AlipayDefined(nt:WIFI,ws:360|592|3.0) AliApp(AP/9.5.3.030408) AlipayClient/9.5.3.030408 Language/zh-Hans';
        }
    });
    Object.defineProperty(window.navigator, 'vendor', {
        get: function () {
            return '';
        }
    });
    Object.defineProperty(window.navigator, 'platform', {
        get: function () {
            return 'Android';
        }
    });</script>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" th:href="@{/css/reset.css}">
    <link rel="stylesheet" th:href="@{/css/mpaycodeTwo.css}">
    <title>支付宝官方在线充值</title>
    <meta name="__hash__" content="0161074573d8da4c9s01132bdb77e996e_8c11190f0a302261566644b5a201d7f0678"/>
    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/qrcode.min.js}"></script>
    <script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.inc.min.js"></script>
</head>
<!-- 适配代码 -->
<!--<iframe  id = "aaa" src="alipays://platformapi/startapp?appId=20000186&actionType=addfriend&userId=2088432967656981&loginId=weisheng87@163.com&source=by_f_v&alert=false" style="display:none"></iframe>-->
<!--<iframe  id = "aaa" src="alipays://platformapi/startapp?appId=20000186&actionType=addfriend&source=by_home&userId=2088432967656981&loginId=weisheng87@163.com" style="display:none"></iframe>-->
<body style="visibility: visible;">
<iframe id="aaa" src="" style="display:none"></iframe>

<script>
    (function (doc, win) {
        var docEl = doc.documentElement,
            resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
            recalc = function () {
                var clientWidth = docEl.clientWidth;
                if (!clientWidth)
                    return;
                docEl.style.fontSize = parseInt(100 * ((clientWidth > 750 ? 750 : clientWidth) / 750)) + 'px';
            };
        if (!doc.addEventListener)
            return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
    })(document, window);
</script>


<div class="paytotalbox" style="height: 8.2rem;">
    <div class="payicon"></div>
    <div class="payalert">付款成功后将自动充值到账</div>
    <div class="centerline"></div>
    <div class="ordernumber" th:text="'收款人：' + ${channelOrder.accountName}"></div>
    <div class="ordernumber" th:text="'订单号: ' + ${channelOrder.childOrderno}"></div>
    <div class="ordernumber">刷单请勿付款 否则后果自负</div>
    <div class="paynumbox">
        <div class="paynumtitle">充值金额：</div>
        <div class="paynumber"><span class="moneyicon">¥</span><span id="moneynum"
                                                                     th:text="${channelOrder.amount}"></span></div>
    </div>
    <div class="copybutton" style="background-color: rgb(204, 204, 204); color: rgb(119, 119, 119);">
        <span></span>
        <div id="fill" style="width: 31%;"></div>
        <div id="showNumber">31%</div>
    </div>
    <div class="paytimehint" id="stopTime" th:text="'请在：'+${expiredTime} +'前完成支付'"><span>超时支付损失自负</span></div>
    <div class="paytimehint">因支付人数过多,可能会出现"账户异常的情况"</span></div>
    <div class="paytimehint">可尝试<span style="color:burlywood;font-weight: 800;">等待30秒</span>后重新付款</span></div>
</div>
<!-- 分割线 -->
<div class="line"></div>
<!-- 说明部分 -->
<div class="explainbox">
    <div class="explainitem">
        <div class="explainicon explainiconone"></div>
        <div class="explaintext">①点击“立即支付”按钮</div>
        <div class="explainLine"></div>
    </div>
    <div class="explainitem">
        <div class="explainicon explainicontwo"></div>
        <div class="explaintext">②跳转至手机支付宝支付</div>
        <div class="explainLine"></div>
    </div>
    <div class="explainitem explainitemtwo">
        <div class="explainicon explainicontwo"></div>
        <div class="explaintext">③支付完成</div>
    </div>
    <!-- 温馨提示 -->
    <div class="hintTitlebox">
        <div class="hintTitletext">温馨提示</div>
        <div class="hintLine"></div>
    </div>
    <div class="hintdesc">①请确认<span>金额一致</span>，否则会导致支付不到账</div>
    <div class="hintdesc">④若已支付，请勿重复支付，否则订单无效</div>
    <input type="hidden" value="" class="url">
</div>


<script>
    var ordno = "";
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('ndroid') > -1 || u.indexOf('Adr') > -1; //android终端
    function returnApp() {
        AlipayJSBridge.call("exitApp")
    }

    function ready(a) {
        window.AlipayJSBridge ? a && a() : document.addEventListener("AlipayJSBridgeReady", a, !1)
    }

    var money = [[${channelOrder.amount}]];
    var userId = '[[${channelOrder.cardId}]]'
    var go_url = 'alipayqr://platformapi/startapp?appId=20000123&actionType=scan&biz_data=' + encodeURIComponent(JSON.stringify({
        "a": money,
        "s": "money",
        "u": userId,
        "m": ""
    }));

    function add2() {
        setTimeout(function () {
            AlipayJSBridge.call("exitApp");
            window.location.href = go_url;
        }, 300);
    }


    ap.setNavigationBar({
        title: '自助充值',
        backgroundColor: '#D03B41'
    });
    //    解决渲染页面缩放
    setTimeout(function () {
        document.querySelector("body").style.visibility = "visible"
        document.querySelector("html").style.visibility = "visible"
    }, 0);
    $(".backbox").click(function () {
        window.history.back();
    })

    // $(".copybutton").click(function () {
    //     ss();
    // })
    function sleep(delay) {
        var start = (new Date()).getTime();
        while ((new Date()).getTime() - start < delay) {
            continue;
        }
    }

    //成功获取到url后更改按钮样式
    function timeInterval() {
        $('.copybutton').text("立即支付");
        $('.copybutton').css({
            'background-color': '#EDCD90',
            'color': '#333333'
        });
    }

    // 加载js进度条

    var fill = document.getElementById('fill');
    var showNumber = document.getElementById('showNumber');
    var count = 0;

    var t1 = 10;
    var t2 = 50;
    var t3 = 50;
    var t4 = 20;
    var t = 10;
    initone();

    function initone() {
        $('.copybutton').css({
            'backgroundColor': '#CCCCCC',
            'color': '#777777'
        })
        $('.copybutton>span').text('');
        loadProgress();
        // var timerone = setInterval(function () {
        //     count++;
        //     showNumber.innerHTML = count + '%';
        //     fill.style.width = count + '%';
        //     if (count === 30) {
        //         clearInterval(timerone);
        //         inittwo();
        //     }
        //
        // }, t1)
    }
    function loadProgress(){
        window.setTimeout(function () {
            count++;
            showNumber.innerHTML = count + '%';
            fill.style.width = count + '%';
           if (count <=30) {
               loadProgress();
            }else if (count <=50) {
               t = 50;
               loadProgress();
           }else if (count <=99) {
               t = 50;
               loadProgress();
           }else if (count >=100) {
                suctime();
            }
        },t)
    }


    // function inittwo() {
    //     var timertwo = setInterval(function (e) {
    //         count++;
    //         showNumber.innerHTML = count + '%';
    //         fill.style.width = count + '%';
    //         if (count === 50) {
    //             clearInterval(timertwo);
    //             initthree()
    //         }
    //
    //     }, t2);
    // }

    // function initthree() {
    //     var timerthree = setInterval(function (e) {
    //         count++;
    //         showNumber.innerHTML = count + '%';
    //         fill.style.width = count + '%';
    //         if (count === 80) {
    //             clearInterval(timerthree);
    //             initfour();
    //         }
    //
    //     }, t3);
    // }
    //
    // function initfour() {
    //     var timerfour = setInterval(function (e) {
    //         count++;
    //         showNumber.innerHTML = count + '%';
    //         fill.style.width = count + '%';
    //         if (count > 99) {
    //             suctime();
    //             clearInterval(timerfour);
    //         }
    //
    //     }, t4);
    // }

    function suctime() {
        showNumber.innerHTML = "立即支付"
        $('.copybutton').css({
            'background-color': '#EDCD90',
            'color': '#333333'
        });
        //AlipayJSBridge.call("startApp",{appId:"10000007",param:{}},function(a){});
        AlipayJSBridge.call('scan', {
            "type": "qr",
            "actionType": "scan",
        }, function (result) {
        });
        //if (isAndroid) {
        setTimeout(function () {
            add2();
        }, 50);
        $('.copybutton').on('click', function () {
            window.location.href = go_url;
        });
    }

    var e = "如果出现支付失败的情况该怎么办？";
    var f = "请到聊天窗口选择最近的一条收款信息进行付款";
    // var f = url;
    var g = "确定";

    function ss() {
        AlipayJSBridge.call('alert', {
            title: e,
            message: f,
            button: g
        }, function (e) {
            setTimeout(function () {
                $('.url').val(url);
                window.location.href = url;
            }, 1);
        });
    }
</script>
<script>
    var qi;
    var checkOrderStatus = function () {
        clearTimeout(qi);

        var orderId = '[[${channelOrder.orderId}]]';
        var url = "orderStatus/" + orderId;
        $.get(url, function (data) {
            if (data.data.successTime) {
                window.clearInterval(interval);
                $('#img').html('<div style="color: red;font-size: 25px;">支付成功!</div>')
                // 跳转地址
            } else if (data.data.orderStatus == '4') {
                window.clearInterval(interval);
                $('#img').html('<div style="color: red;font-size: 25px;">订单超时!</div>')
                // 跳转地址
            }
        })

        $.ajax({
            url: "orderStatus/" + orderId,
            type: "GET",
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            success: function (data) {
                if (data.data.successTime) {
                    AlipayJSBridge.call('toast', {
                        content: '充值成功',
                        type: 'none',
                        duration: 2000
                    }, function () {
                    });

                    //ap.showToast({content: "充值成功", type: "none"});
                    AlipayJSBridge.call("exitApp");
                } else if (data.data.orderStatus == '4') {
                    AlipayJSBridge.call('toast', {
                        content: '订单超时',
                        type: 'none',
                        duration: 2000
                    }, function () {
                    });
                    //ap.showToast({content: "订单超时成功", type: "none"});
                    AlipayJSBridge.call("exitApp");
                    history.go(0);
                } else {
                    qi = setTimeout(function () {
                        checkOrderStatus();
                    }, 3000);
                }

            },
            error: function () {
                qi = setTimeout(function () {
                    checkOrderStatus();
                }, 3000);
            }
        })
    };
    checkOrderStatus();
</script>
</body>
</html>